/*
 * BSM6.0
 *
 * Copyright 2012-2013 (C) SINODATA CO., LTD. All Rights Reserved.
 */
package com.sinodata.bsm.center.web.action.appview;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.codehaus.jackson.annotate.JsonAnyGetter;
import org.springframework.beans.factory.annotation.Autowired;

import com.sinodata.bsm.center.bean.PropValueBean;
import com.sinodata.bsm.center.bean.ResBean;
import com.sinodata.bsm.center.bean.ResTypeBean;
import com.sinodata.bsm.center.cache.MotiResRelCache;
import com.sinodata.bsm.center.cache.NewEventCache;
import com.sinodata.bsm.center.cache.PropertyCache;
import com.sinodata.bsm.center.cache.PropertyValueCache;
import com.sinodata.bsm.center.cache.ProtocolParameterCache;
import com.sinodata.bsm.center.cache.ResCache;
import com.sinodata.bsm.center.cache.ResGroupCache;
import com.sinodata.bsm.center.service.resource.AttributeService;
import com.sinodata.bsm.center.util.web.Struts2Utils;
import com.sinodata.bsm.center.web.action.BaseAction;
import com.sinodata.bsm.common.constants.ResConstants;
import com.sinodata.bsm.common.utils.DateUtil;
import com.sinodata.bsm.common.utils.StringUtil;
import com.sinodata.bsm.common.vo.Event;
import com.sinodata.bsm.common.vo.MotiResRel;
import com.sinodata.bsm.common.vo.Property;
import com.sinodata.bsm.common.vo.ProtocolParameter;
import com.sinodata.bsm.common.vo.Res;
import com.sinodata.bsm.common.vo.ResAttrVal;
import com.sinodata.bsm.common.vo.ResGroup;

/**
 * <p>
 * Description:
 * </p>
 * 
 * @author wangyazhou
 * @version 1.0
 * 
 * <p>
 * History:
 * 
 * Date Author Version Description
 * ---------------------------------------------------------------------------------
 * 2013-5-17 下午3:21:09 wangyazhou 1.0 To create
 * </p>
 * 
 * @since
 * @see
 */
@SuppressWarnings("rawtypes")
public class AppDetailAction extends BaseAction {

    private static final long serialVersionUID = 1L;

    private static Long WINPROC = 1205020100000L;

    private static Long UNIXPROC = 1205020200000L;

    private static Long PORT = 1201080000000L;

    private static Long FILE_PROC = 1205010100000L;

    private static Long FILE_CONT = 1205010300000L;

    private static Long SQL = 1205040200000L;

    private static Long SHELL = 1205040300000L;

    @Autowired
    private PropertyValueCache propertyValueCache;

    @Autowired
    private AttributeService attributeService;

    @Autowired
    private ProtocolParameterCache protocolParameterCache;

    @Autowired
    private ResCache resCache;

    @Autowired
    private NewEventCache newEventCache;

    @Autowired
    private PropertyCache propertyCache;

    @Autowired
    private ResGroupCache resGroupCache;

    @Autowired
    private MotiResRelCache motiResRelCache;

    public String initAppDetailData() {

        String resId = Struts2Utils.getParameter("resId");
        JSONObject json = new JSONObject();
        try {
            ResBean[] childBeans = ResBean.get(Long.parseLong(resId)).children();
            if (childBeans == null) {
                return null;
            }
            JSONArray procArry = new JSONArray();
            JSONArray portArry = new JSONArray();
            JSONArray fileArry = new JSONArray();
            JSONArray sqlArry = new JSONArray();
            JSONArray shellArry = new JSONArray();

            for (ResBean resBean : childBeans) {
                Long resTypeId = resBean.res().getResTypeId();
                Res res = resBean.res();
                // win进程
                if (WINPROC.equals(resTypeId)) {
                    JSONObject obj = new JSONObject();
                    ResAttrVal attrVal = attributeService.getResAttrVal(res.getId(), 120502010000001L);
                    obj.element("name", attrVal == null ? "unKnown" : attrVal.getAttrValue());
                    String cpu = propertyValueCache.getValue(res.getId(), 120502010000002L);
                    obj.element("status", (cpu == null || cpu.length() < 1) ? "U" : "R");

                    obj.element("id", res.getId());
                    obj.element("ip", res.getIp());

                    obj.element("cpu", (cpu == null || cpu.length() < 1) ? "0" : cpu);
                    String mem = propertyValueCache.getValue(res.getId(), 120502010000003L);
                    obj.element("mem", (mem == null || mem.length() < 1) ? "0" : mem);
                    String dur = propertyValueCache.getValue(res.getId(), 120502010000004L);
                    if (dur == null || dur.length() < 1) {
                        dur = 0 + "";
                    }
                    Long day = Long.parseLong(dur) / 3600 / 24;
                    Long hour = Long.parseLong(dur) % (3600 * 24) / 3600;
                    Long min = Long.parseLong(dur) % 3600 / 60;
                    Long sec = Long.parseLong(dur) % 60;

                    String durTime = (day == 0 ? "" : day + "天") + (hour == 0 ? "" : hour + "时") + (min == 0 ? "" : min + "分") + (sec == 0 ? "" : sec + "秒");
                    obj.element("duration", durTime);

                    procArry.add(obj);
                }
                // linux 进程
                if (UNIXPROC.equals(resTypeId)) {
                    JSONObject obj = new JSONObject();
                    ResAttrVal attrVal = attributeService.getResAttrVal(res.getId(), 120502020000002L);
                    obj.element("name", attrVal == null ? "unKnown" : attrVal.getAttrValue());

                    obj.element("id", res.getId());
                    String status = propertyValueCache.getValue(res.getId(), 120502020000003L);
                    obj.element("status", (status == null || status.length() < 1) ? "U" : status);
                    obj.element("ip", res.getIp());
                    String cpu = propertyValueCache.getValue(res.getId(), 120502020000001L);
                    obj.element("cpu", (cpu == null || cpu.length() < 1) ? "0" : cpu);
                    String mem = propertyValueCache.getValue(res.getId(), 120502020000002L);
                    obj.element("mem", (mem == null || mem.length() < 1) ? "0" : mem);
                    String dur = propertyValueCache.getValue(res.getId(), 120502020000004L);
                    if (dur == null || dur.length() < 1) {
                        dur = 0 + "";
                    }
                    Long day = Long.parseLong(dur) / 3600 / 24;
                    Long hour = Long.parseLong(dur) % (3600 * 24) / 3600;
                    Long min = Long.parseLong(dur) % 3600 / 60;
                    Long sec = Long.parseLong(dur) % 60;

                    String durTime = (day == 0 ? "" : day + "天") + (hour == 0 ? "" : hour + "时") + (min == 0 ? "" : min + "分") + (sec == 0 ? "" : sec + "秒");

                    obj.element("duration", durTime);
                    procArry.add(obj);
                }

                // 端口
                if (PORT.equals(ResTypeBean.get(resTypeId).resType().getParentId())) {

                    JSONObject obj = new JSONObject();
                    obj.element("name", res.getName());
                    obj.element("id", res.getId());
                    String status = propertyValueCache.getValue(res.getId(), 120108000000001L);
                    obj.element("status", (status == null || status.length() < 1) ? "未知" : status);
                    String cnt = propertyValueCache.getValue(res.getId(), 120108000000002L);
                    obj.element("cnt", (cnt == null || cnt.length() < 1) ? "未知" : cnt);
                    obj.element("ip", res.getIp());
                    portArry.add(obj);
                }

                // 文件进度
                if (FILE_PROC.equals(resTypeId)) {
                    JSONObject obj = new JSONObject();
                    obj.element("type", "查看文件进度");
                    obj.element("id", res.getId());
                    obj.element("ip", res.getIp());
                    obj.element("name", res.getName());

                    String file = "";
                    if (attributeService.getResAttrVal(res.getId(), 120501010000001L) != null) {
                        file = attributeService.getResAttrVal(res.getId(), 120501010000001L).getAttrValue();
                    }
                    String reg = "";
                    if (attributeService.getResAttrVal(res.getId(), 120501010000002L) != null) {
                        reg = attributeService.getResAttrVal(res.getId(), 120501010000002L).getAttrValue();
                    }
                    obj.element("file", ("".equals(reg)) ? file + "" : file + " [" + reg + "] ");

                    fileArry.add(obj);
                }

                // 文件内容
                if (FILE_CONT.equals(resTypeId)) {
                    JSONObject obj = new JSONObject();
                    obj.element("type", "文件内容过滤");
                    obj.element("ip", res.getIp());
                    obj.element("id", res.getId());
                    obj.element("name", res.getName());
                    String file = "";
                    if (attributeService.getResAttrVal(res.getId(), 120501030000001L) != null) {
                        file = attributeService.getResAttrVal(res.getId(), 120501030000001L).getAttrValue();
                    }
                    String reg = "";
                    if (attributeService.getResAttrVal(res.getId(), 120501030000002L) != null) {
                        attributeService.getResAttrVal(res.getId(), 120501030000002L).getAttrValue();
                    }
                    String filter = "";
                    if (attributeService.getResAttrVal(res.getId(), 120501030000003L) != null) {
                        filter = attributeService.getResAttrVal(res.getId(), 120501030000003L).getAttrValue();
                    }

                    obj.element("file", "".equals(reg) ? file + "" : file + " [" + reg + "] " + ("".equals(filter) ? "" : " &gt;&gt; " + filter));

                    fileArry.add(obj);
                }

                // sql
                if (SQL.equals(resTypeId)) {
                    JSONObject obj = new JSONObject();
                    obj.element("ip", res.getIp());
                    obj.element("name", res.getName());
                    obj.element("id", res.getId());
                    String type = "";
                    if (attributeService.getResAttrVal(res.getId(), 120504020000001L) != null) {
                        type = attributeService.getResAttrVal(res.getId(), 120504020000001L).getAttrValue();
                    }
                    String inst = "";
                    if (attributeService.getResAttrVal(res.getId(), 120504020000002L) != null) {
                        inst = attributeService.getResAttrVal(res.getId(), 120504020000002L).getAttrValue();
                    }

                    obj.element("db", type + "：" + inst);
                    String sql = "";
                    if (attributeService.getResAttrVal(res.getId(), 120504020000003L) != null) {
                        sql = attributeService.getResAttrVal(res.getId(), 120504020000003L).getAttrValue();
                    }

                    obj.element("sql", sql);

                    sqlArry.add(obj);
                }

                // shell
                if (SHELL.equals(resTypeId)) {
                    JSONObject obj = new JSONObject();
                    obj.element("name", res.getName());
                    obj.element("ip", res.getIp());
                    obj.element("id", res.getId());
                    ProtocolParameter protocolParameter = getProtocol(res.getIp(), "HOST");
                    obj.element("user", protocolParameter == null ? "没有配置登录用户信息" : protocolParameter.getUserName());

                    String shell = attributeService.getResAttrVal(res.getId(), 120504030000001L).getAttrValue();

                    String reg = "";
                    if (attributeService.getResAttrVal(res.getId(), 120504030000002L) != null) {
                        reg = attributeService.getResAttrVal(res.getId(), 120504030000002L).getAttrValue();
                    }

                    obj.element("shell", shell.replace(">", "&gt;").replace("<", "&lt;") + ("".equals(reg) ? "" : " &gt;&gt; " + reg));

                    shellArry.add(obj);
                }
            }

            json.element("procs", procArry);
            json.element("ports", portArry);
            json.element("files", fileArry);
            json.element("sqls", sqlArry);
            json.element("shells", shellArry);

            Struts2Utils.renderText(json.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 根据IP TYPE 获取一条配置信息
     * 
     * @param ip
     * @param type
     * @return
     */
    public ProtocolParameter getProtocol(String ip, String type) {
        List<ProtocolParameter> list = protocolParameterCache.getAll();
        if (list == null || ip == null || ip.length() < 1 || type == null || type.length() < 1) {
            return null;
        }
        for (ProtocolParameter pro : list) {
            if (ip.equals(pro.getIp()) && type.equals(pro.getType())) {
                return pro;
            }
            continue;
        }
        return null;
    }

    /**
     * 显示资源的健康状况、可用性的统计
     * 
     * @return
     */

    public String viewResBase() {
        try {
            String resId = Struts2Utils.getParameter("resid");
            Res res = resCache.get(Long.valueOf(resId));
            JSONObject jsonObject = buildResBaseChart(res);
            ResTypeBean bean = null;
            List<Res> resList = new ArrayList<Res>();
            List<ResGroup> resGroups = resGroupCache.findByResId(Long.valueOf(resId));
            ResGroup jkglGroup = null;
            List<MotiResRel> motiResRels = null;
            if (resGroups != null) {
                for (ResGroup group : resGroups) {
                    if (group.getContainType() != null && group.getContainType() == 1000L) {
                        jkglGroup = group;
                        break;
                    }
                }
            }
            if (jkglGroup != null) {
                motiResRels = motiResRelCache.findByResGroupId(jkglGroup.getId());
            }
            Map<Long, String[]> useabalityMap = new HashMap<Long, String[]>();
            Map<Long, List<Property>> resPropertyMap = new HashMap<Long, List<Property>>();
            String[] healthArr = ResConstants.HEALTH_DESC;
            String healthStatus = healthArr[res.getHealthStatus() - 1];
            // 业务状态的列表数据封装
            Map<Long, String> fusionMap = new HashMap<Long, String>();
            for (MotiResRel motiResRel : motiResRels) {
                ResBean b = ResBean.get(motiResRel.getResId());
                //判断了应用类型、
                if ((bean = b.type().parent()) != null && (bean.resType().getId() == 1105060000000L || bean.resType().getId() == 1105010000000L || bean.resType().getId() == 1105030000000L || bean.resType().getId() == 1105040000000L)) {
                    // 构建表头的柱状图 暂时没用
                    JSONObject columnbject = buildUsabilityColumn();
                    fusionMap.put(b.res().getId(), columnbject.toString());
                    resList.add(b.res());
                    StringBuffer lastPropValueBuffer = new StringBuffer();
                    // 新事件数 并且取出最新的事件时间
                    List<Event> events = newEventCache.getNewEventsByResId(b.res().getId());
                    List<Property> propertyList = ResTypeBean.get(b.res().getResTypeId()).properties();

                    List<PropValueBean> propValueBeanList = new ArrayList<PropValueBean>();
                    //为了显示效果 暂定为propertyList 实际上必须的存PropValueBean对象
                    resPropertyMap.put(b.res().getId(), propertyList);
                    if (propertyList != null) {
                        for (Property property : propertyList) {
                            PropValueBean propvalueBean = propertyValueCache.getValueBean(b.res().getId(), property.getId());

                            if (propvalueBean != null)
                                propValueBeanList.add(propvalueBean);
                        }
                    }

                    if (propValueBeanList != null && propValueBeanList.size() > 0) {
                        Collections.sort(propValueBeanList, new Comparator<PropValueBean>() {
                            public int compare(PropValueBean propValueBean1, PropValueBean propValueBean2) {
                                // TODO Auto-generated method stub
                                return propValueBean2.getTime().compareTo(propValueBean1.getTime());
                            }
                        });
                        Date lastPropValueDate = propValueBeanList.get(0).getTime();
                        Long spaceTime = (new Date()).getTime() - lastPropValueDate.getTime();
                        lastPropValueBuffer = lastPropValueUtils(spaceTime);

                    }
                    if (StringUtil.isEmpty(lastPropValueBuffer.toString())) {
                        lastPropValueBuffer.append("-");
                    }
                    // 将事件数，最后采集时间，最后更新的事件数存入数组中
                    useabalityMap.put(b.res().getId(), new String[] { lastPropValueBuffer.toString(), String.valueOf(events != null && events.size() > 0 ? events.size() : 0) });

                }
            }
            Struts2Utils.setRequestAttribute("resPropertyMap", resPropertyMap);
            Struts2Utils.setRequestAttribute("useabalityMap", useabalityMap);
            Struts2Utils.setRequestAttribute("healthStatus", healthStatus);
            Struts2Utils.setRequestAttribute("resList", resList);
            Struts2Utils.setRequestAttribute("fusionMap", fusionMap);
            Struts2Utils.setRequestAttribute("resBaseChart", jsonObject.toString());
            Struts2Utils.setRequestAttribute("res", res);
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
        }
        return "view";
    }

    /**
     * 最后采集时间的计算
     * 
     * @param spaceTime
     * @return
     */
    private StringBuffer lastPropValueUtils(Long spaceTime) {
        StringBuffer lastPropValueBuffer = new StringBuffer();
        int second = 1000;// 秒
        int minute = second * 60;
        int hour = minute * 60;
        int day = hour * 24;
        if (spaceTime > 0) {
            // 秒的情况
            if (spaceTime > 0 && spaceTime <= minute) {
                lastPropValueBuffer.append(spaceTime / 1000);
                lastPropValueBuffer.append("秒");
            }
            // 分钟
            if (spaceTime > minute && spaceTime <= hour) {
                lastPropValueBuffer.append(spaceTime / minute);
                lastPropValueBuffer.append("分");
            }
            // 时
            if (spaceTime > hour && spaceTime <= day) {
                lastPropValueBuffer.append(spaceTime / hour);
                lastPropValueBuffer.append("时");
            }
            // 天
            if (spaceTime >= day) {
                lastPropValueBuffer.append(spaceTime / day);
                lastPropValueBuffer.append("天");
            }
            lastPropValueBuffer.append("前");
        }
        return lastPropValueBuffer;
    }

    public String viewResState() {
        String resId = Struts2Utils.getParameter("resId");
        Res res = resCache.get(Long.parseLong(resId));
        ResBean resBean = ResBean.get(Long.valueOf(resId));
        ResBean[] resArray = resBean.children();
        ResTypeBean bean = null;
        List<Res> resList = new ArrayList<Res>();
        JSONObject jsonChart = new JSONObject();
        for (ResBean b : resArray) {
            JSONObject jsonObject = new JSONObject();
            if ((bean = b.type().parent()) != null && (bean.resType().getId() == 1105060000000L || bean.resType().getId() == 1105010000000L || bean.resType().getId() == 1105030000000L || bean.resType().getId() == 1105040000000L)) {
                resList.add(b.res());
            }
            // 新事件数
            List events = newEventCache.getNewEventsByResId(res.getId());
            jsonObject.element("eventsNumber", events.size());
            // jsonObject.element("propLastTime", propertyValueCache.get);
            JSONObject chatObject = buildResHealthDegreeLED(b.res());
            jsonObject.element(String.valueOf(b.res().getId()), chatObject);

        }
        return "viewdetail5";
    }

    /**
     * 创建资源健康度LED图示
     * 
     * @param res
     * @return
     */
    private JSONObject buildResHealthDegreeLED(Res res) {
        JSONObject jsonObject = new JSONObject();
        JSONObject chart = new JSONObject();
        chart.element("manageResize", "1");
        chart.element("chartLeftMargin", "2");
        chart.element("chartRightMargin", "2");
        chart.element("chartTopMargin", "2");
        chart.element("chartBottomMargin", "2");
        chart.element("palette", "5");
        chart.element("lowerLimit", "0");
        chart.element("showBorder", "0");
        chart.element("showValue", "0");
        chart.element("showTickMarks", "0");
        chart.element("upperLimit", "100");
        chart.element("majorTMColor", "333333");
        chart.element("majorTMAlpha", "100");
        chart.element("majorTMHeight", "10");
        chart.element("majorTMThickness", "2");
        chart.element("minorTMColor", "666666");
        chart.element("minorTMAlpha", "100");
        chart.element("minorTMHeight", "7");
        chart.element("useSameFillColor", "1");
        JSONArray color = buildHealtColor();
        jsonObject.element("colorrange", color);
        jsonObject.element("value", res.getHealthDegree());
        jsonObject.element("chart", chart);
        return jsonObject;
    }

    private JSONArray buildHealtColor() {
        JSONArray color = new JSONArray();
        int maxValue = 20;
        for (int i = 1; i <= 5; i++) {
            JSONObject obj = new JSONObject();
            if (i == 1)
                obj.element("minValue", "0");
            else
                obj.element("minValue", ((i - 1) * maxValue + 1));
            obj.element("maxValue", maxValue * i);
            switch (i) {
                case 1:
                    obj.element("code", "#ce110f");
                    break;
                case 2:
                    obj.element("code", "#ff9937");
                    break;
                case 3:
                    obj.element("code", "#dede03");
                    break;
                case 4:
                    obj.element("code", "#56a8f4");
                    break;
                case 5:
                    obj.element("code", "#2cb900");
                    break;
                default:
                    break;
            }
            color.add(obj);
        }
        return color;
    }

    private JSONObject buildUsabilityColumn() {
        JSONObject jsonObject = new JSONObject();
        JSONObject chartObject = new JSONObject();
        chartObject.element("palette", "1");
        chartObject.element("bgColor", "#ecf6fc");
        chartObject.element("bgAlpha", "80");
        chartObject.element("captionPadding", "1");
        chartObject.element("chartLeftMargin", "1");
        chartObject.element("caption", "当前可用性：可用");
        chartObject.element("chartRightMargin", "1");
        chartObject.element("labelDisplay", "WRAP");
        chartObject.element("chartBottomMargin", "1");
        chartObject.element("chartTopMargin", "1");
        chartObject.element("chartBottomMargin", "1");
        chartObject.element("showBorder", "0");
        chartObject.element("showValues", "1");
        chartObject.element("decimals", "0");
        chartObject.element("formatNumberScale", "0");

        JSONArray dataJsonArray = new JSONArray();
        JSONObject todayObject = new JSONObject();
        todayObject.element("label", "今天");
        todayObject.element("value", "20");
        todayObject.element("color", "F6BD0F");

        JSONObject yesterdayObject = new JSONObject();
        yesterdayObject.element("label", "昨天");
        yesterdayObject.element("value", "40");
        yesterdayObject.element("color", "F6BD0F");

        JSONObject monthObject = new JSONObject();
        monthObject.element("label", "当月");
        monthObject.element("value", "60");
        monthObject.element("color", "F6BD0F");

        JSONObject lastmonthObject = new JSONObject();
        lastmonthObject.element("label", "上月");
        lastmonthObject.element("value", "80");
        lastmonthObject.element("color", "F6BD0F");

        dataJsonArray.add(todayObject);
        dataJsonArray.add(yesterdayObject);
        dataJsonArray.add(monthObject);
        dataJsonArray.add(lastmonthObject);

        jsonObject.element("chart", chartObject);
        jsonObject.element("data", dataJsonArray);
        return jsonObject;
    }

    /**
     * 构建资源健康状况的仪表盘图
     * 
     * @param res
     * @return
     */
    private JSONObject buildResBaseChart(Res res) {
        JSONObject jsonObject = new JSONObject();
        JSONObject chart = new JSONObject();
        chart.element("bgColor", "#ecf6fc");
        chart.element("bgAlpha", "100");
        chart.element("showTickValues", "1");
        chart.element("showBorder", "0");
        chart.element("lowerLimit", "0");
        chart.element("fontcolor", "000000");
        chart.element("upperLimit", "100");
        chart.element("majorTMColor", "FFFFFF");
        chart.element("majorTMAlpha", "1");
        chart.element("majorTMNumber", "6");
        chart.element("minorTMNumber", "0");
        chart.element("tickValueStep", "1");
        chart.element("tickValueDistance", "10");
        chart.element("showTickMarks", "1");
        chart.element("showBorder", "0");
        chart.element("basefontColor", "000000");
        chart.element("chartTopMargin", "5");
        chart.element("chartLeftMargin", "1");
        chart.element("chartBottomMargin", "5");
        chart.element("gaugeInnerRadius", "0");
        chart.element("gaugeOuterRadius", "60");
        chart.element("fillAngle", "50");
        chart.element("chartLeftMargin", "0");
        chart.element("chartRightMargin", "0");
        chart.element("toolTipBgColor", "80A905");
        JSONObject colorrangeObject = new JSONObject();
        JSONArray color = buildHealtColor();
        colorrangeObject.element("color", color);
        JSONObject dialObject = new JSONObject();
        JSONArray dialArray = new JSONArray();
        JSONObject dialObj = new JSONObject();
        dialObj.element("value", res.getHealthDegree());
        dialObj.element("rearExtension", "10");
        dialObj.element("radius", "55");
        dialArray.add(dialObj);
        dialObject.element("dial", dialArray);

        jsonObject.element("chart", chart);
        jsonObject.element("colorrange", colorrangeObject);
        jsonObject.element("dials", dialObject);
        return jsonObject;
    }

    @Override
    public Object getModel() {
        return null;
    }

    @Override
    public String list() throws Exception {
        return null;
    }

    @Override
    public String input() throws Exception {
        return null;
    }

    @Override
    public String save() throws Exception {
        return null;
    }

    @Override
    public String delete() throws Exception {
        return null;
    }

    @Override
    protected void prepareModel() throws Exception {

    }

    public static void main(String[] args) {
        Long time = 1000L * 60 * 60;
        System.out.println(time / (1000 * 60 * 60 * 24));
    }

}
